<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('离职管理')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
                    <input type="hidden" id="ComPidorDepTid" name="ComPidorDepTid">
                    <div class="select-list">
                        <ul>
                            <li>
                                姓名：<input type="text" name="name"/>
                            </li>
                            <li>
                                工号：<input type="text" name="badge"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()">
                    <i class="fa fa-plus"></i> 添加员工
                </a>
                <a class="btn btn-primary single" onclick="$.operate.edit()">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
                &nbsp;&nbsp;&nbsp;
                <a class="btn btn-primary" onclick="cc('eSP_LeaveCheck')">
                    <i class="fa fa-edit"></i> 确认检查
                </a>
                <a class="btn btn-danger" onclick="cc('eSP_LeaveCancel')">
                    <i class="fa fa-remove"></i> 取消确认
                </a>
                <a class="btn btn-primary" onclick="cc('eSP_LeaveStart')">
                    执行离职处理
                </a>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>

<script th:inline="javascript">
    var prefix = ctx + "quitManage/quitEmpRegister";
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        queryData();
    });

    function queryData() {
        var columns = [];
        var checkbox = {checkbox: true};
        var id = {field: 'id', title: '序号'};
        var badge = {field: 'badge', title: '工号'};
        var name = {field: 'name', title: '姓名'};
        var compName = {field: 'compName', title: '公司'};
        var depName = {field: 'depName', title: '部门'};
        var jobName = {field: 'jobName', title: '岗位'};
        var JoinDate = {field: 'JoinDate', title: '入职日期'};
        var jointypeTitle = {field: 'jointypeTitle', title: '入职渠道'};
        var ApplyDate = {field: 'ApplyDate', title: '申请离职日期'};
        var LeaveDate = {field: 'LeaveDate', title: '实际离职日期'};
        var LeaveTypeTile = {field: 'LeaveTypeTile', title: '离职类型'};
        var LeaveReasonTitle = {field: 'LeaveReasonTitle', title: '离职原因'};
        var lzyy = {field: 'lzyy', title: '离职详因'};
        var isEndCon = {title: '同步接触合同?',
            formatter: function (value, row, index) {
                return EndCon(row);
            }
        };
        var isPay = {field: 'isPay', title: '支付违约金?',
            formatter: function (value, row, index) {
                return Pay(row);
            }
        };
        var PayFee = {field: 'PayFee', title: '违约金'};
        var IsExpenses = {title: '支付经济补偿金?',
            formatter: function (value, row, index) {
                return Expenses(row);
            }
        };
        var ExpenseFee = {field: 'ExpenseFee', title: '经济补偿金'};
        var Iscompete = {field: 'Iscompete', title: '是否竞业限制?',
            formatter: function (value, row, index) {
                return compete(row);
            }
        };
        var competeFee = {field: 'competeFee', title: '竞业限制金'};
        var isBlackList = {title: '是否黑名单?',
            formatter: function (value, row, index) {
                return BlackList(row);
            }
        };
        var WFStatus = {field: 'WFStatus', title: '流程状态'};
        var SeqID = {field: 'SeqID', title: '关联ID'};
        var Remark = {field: 'Remark', title: '备注'};
        var RegByName = {field: 'RegByName', title: '登记人'};
        var RegDate = {field: 'RegDate', title: '登记时间'};
        var Initialized = {title: '?确认',
            formatter: function (value, row, index) {
                return initialized(row);
            }
        };
        var InitializedByName = {field: 'InitializedByName', title: '确认人'};
        var InitializedTime = {field: 'InitializedTime', title: '确认时间'};
        var ezid = {field: 'ezid', title: '人事区域'};

        columns.push(checkbox,id,badge,name,compName,depName,jobName,JoinDate,jointypeTitle,ApplyDate);
        columns.push(LeaveDate,LeaveTypeTile,LeaveReasonTitle,lzyy,isEndCon,isPay,PayFee,IsExpenses);
        columns.push(ExpenseFee,Iscompete,competeFee,isBlackList,WFStatus,SeqID,Remark,RegByName);
        columns.push(RegDate,Initialized,InitializedByName,InitializedTime,ezid);

        var options = {
            code: "id",
            uniqueId: "id",
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            height: $(window).height() - 120,
            sortOrder: "desc",
            modalName: "员工离职登记",
            columns: columns
        };
        $.table.init(options);
    }


    //同步解除合同
    function EndCon(row) {
        if (row.isEndCon == 0 || row.isEndCon == null || row.isEndCon == '') {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\"';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\"';
        }
    }

    //支付违约金
    function Pay(row) {
        if (row.isPay == 0 || row.isPay == null || row.isPay == '') {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\"';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\"';
        }
    }

    //支付经济补偿金
    function Expenses(row) {
        if (row.IsExpenses == 0 || row.IsExpenses == null || row.IsExpenses == '') {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\"';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\"';
        }
    }

    //是否竞业限制
    function compete(row) {
        if (row.Iscompete == 0 || row.Iscompete == null || row.Iscompete == '') {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\"';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\"';
        }
    }

    //是否黑名单
    function BlackList(row) {
        if (row.isBlackList == 0 || row.isBlackList == null || row.isBlackList == '') {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\"';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\"';
        }
    }

    //是否确认
    function initialized(row) {
        if (row.Initialized == 0 || row.Initialized == null || row.Initialized == '') {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\"';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\"';
        }
    }

    function cc(procedure){
        var allId = "";
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allId += row[i].id
            } else {
                allId += row[i].id + ","

            }
        }
        $.ajax({
            url: prefix + "/procedure",
            data: {"allId": allId, "procedure": procedure},
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.data == null) {
                    $.modal.alertWarning(data.message);
                } else {
                    $.modal.alertSuccess(data.data);
                }

                $.table.refresh();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });

    }



</script>
</body>
</html>